<script src="<?php echo base_url();?>js/knockout-1.2.1.js"></script>

<p>&nbsp;</p>
<div align="center">
  <h1>ตารางกรอกข้อมูลคุณภาพสินค้า Folio Sheet</h1>
</div>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="font">
  <tr>
    <td width="8%" height="40">Type</td>
    <td width="26%" height="40"> :
      <select class="select" id="ticket1">
        <option value="PPC PMW">PPC PMW</option>
        <option value="LPP">LPP</option>
        <option value="OSP PRO-NEW">OSP PRO-NEW</option>
      </select></td>
    <td width="8%" height="40">Size</td>
    <td width="25%" height="40"> :
      <select name="ticket" class="select" id="ticket4">
        <option value="24&quot;x35&quot;">24&quot;x35&quot;</option>
        <option value="31&quot;x43&quot;">31&quot;x43&quot;</option>
        <option value="etc">etc</option>
      </select></td>
    <td width="8%" height="40">Date</td>
    <td width="25%" height="40"> :
      <input id="datepicker" data-bind="value: departure" /></td>
  </tr>
  <tr>
    <td height="40">Gram</td>
    <td height="40"> :
      <select class="select" id="ticket2">
        <option value="60">60</option>
        <option value="64">64</option>
        <option value="70">70</option>
        <option value="75">75</option>
        <option value="80">80</option>
        <option value="90">90</option>
        <option value="100">100</option>
      </select></td>
    <td height="40">Lot No.</td>
    <td height="40"> :
      <input name="textfield" type="text" class="k-textbox" id="lot_no"/></td>
    <td height="40">Shift</td>
    <td height="40"> :
      <select class="select" id="ticket7">
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="C">C</option>
      </select></td>
  </tr>
  <tr>
    <td height="40">Grade </td>
    <td height="40"> :
      <select name="ticket4" class="select" id="ticket3">
        <option value="A">A</option>
        <option value="H">H</option>
        <option value="R">R</option>
      </select></td>
    <td height="40">Position</td>
    <td height="40"> :
      <select name="ticket5" class="select" id="ticket5">
        <option value="หัว">หัว</option>
        <option value="กลาง">กลาง</option>
        <option value="ท้าย">ท้าย</option>
      </select></td>
    <td height="40">Time</td>
    <td height="40"> :
      <input type="text" name="textfield2" id="timepicker" /></td>
  </tr>
  <tr>
    <td height="40">Problem </td>
    <td height="40"> :
      <input name="textfield68" type="text" class="k-textbox" id="Problem"/></td>
    <td height="40">Sorter</td>
    <td height="40"> :
      <select name="ticket3" class="select" id="ticket6">
        <option value="N">N</option>
        <option value="S">S</option>
        <option value="N/C">N/C</option>
        <option value="ETC">ETC</option>
      </select></td>
    <td height="40">&nbsp;</td>
    <td height="40">&nbsp;</td>
  </tr>
</table>
<br />
<table width="99%" align="center">
  <tr>
    <td><div align="right"> <span id="loading"></span>
      <input name="Submit" id="submit" type="submit" class="k-button" value="บันทึกข้อมูล"/>
      &nbsp;
      <input name="Reset" type="reset" class="k-button" value="ยกเลิก"/>
    </div></td>
  </tr>
</table>
<table width="99%" align="center" class="font">
  <tr>
    <td><table id="grid">
        <thead>
          <tr>
            <th data-field="rank">Properties Item</th>
            <th data-field="rating">Value</th>
            <th data-field="title">Unit</th>
            <th data-field="year">Properties Item</th>
            <th data-field="dse">Value</th>
            <th data-field="asa">Unit</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>พื้นที่สกปรก ( Dirt )</td>
            <td><input name="fs12_1" type="number" value="0" class="k-textbox number" id="fs12_1"/></td>
            <td>ppm.</td>
            <td><strong>ฉลากสินค้า/คุณภาพการหีบห่อ</strong></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>จำนวนแผ่นสกปรก /45 แผ่น</td>
            <td><input name="fs13_1" type="number" value="0" class="k-textbox number" id="fs13_1"/></td>
            <td>แผ่น</td>
            <td>แกรม</td>
            <td><input name="fs22_1" type="number" value="0" class="k-textbox number" id="fs22_1"/></td>
            <td>1 = ถูกต้อง,   2= ไม่ถูกต้อง</td>
          </tr>
          <tr>
            <td>ลักษณะขุยกระดาษ</td>
            <td><input name="fs14_1" type="number" value="0" class="k-textbox number" id="fs14_1"/></td>
            <td>No.</td>
            <td>ขนาด</td>
            <td><input name="fs23_1" type="number" value="0" class="k-textbox number" id="fs23_1"/></td>
            <td>1 = ถูกต้อง,   2= ไม่ถูกต้อง</td>
          </tr>
          <tr>
            <td>การวางแนวเกรนกระดาษ</td>
            <td><input name="fs15_1" type="number" value="0" class="k-textbox number" id="fs15_1"/></td>
            <td>1=Long grain,2=Shot grain</td>
            <td>Mat no.</td>
            <td><input name="fs24_1" type="number" value="0" class="k-textbox number" id="fs24_1"/></td>
            <td>1 = ถูกต้อง,   2= ไม่ถูกต้อง</td>
          </tr>
          <tr>
            <td>จำนวนแผ่น (500 แผ่น)</td>
            <td><input name="fs16_1" type="number" value="0" class="k-textbox number" id="fs16_1"/></td>
            <td>แผ่น</td>
            <td>Lot no.</td>
            <td><input name="fs25_1" type="number" value="0" class="k-textbox number" id="fs25_1"/></td>
            <td>1 = ถูกต้อง,   2= ไม่ถูกต้อง</td>
          </tr>
          <tr>
            <td>ขนาดแผ่นกระดาษ</td>
            <td><input name="fs17_1" type="number" value="0" class="k-textbox number" id="fs17_1"/></td>
            <td>mm.</td>
            <td>จำนวนรีม</td>
            <td><input name="fs26_1" type="number" value="0" class="k-textbox number" id="fs26_1"/></td>
            <td>รีม</td>
          </tr>
          <tr>
            <td>ฉากกระดาษ ด้านกว้าง</td>
            <td><input name="fs18_1" type="number" value="0" class="k-textbox number" id="fs18_1"/></td>
            <td>mm.</td>
            <td>ความสูงตั้ง</td>
            <td><input name="fs27_1" type="number" value="0" class="k-textbox number" id="fs27_1"/></td>
            <td>cm.</td>
          </tr>
          <tr>
            <td>ฉากกระดาษ ด้านยาว</td>
            <td><input name="fs19_1" type="number" value="0" class="k-textbox number" id="fs19_1"/></td>
            <td>mm.</td>
            <td>สภาพตั้ง/ห่อรีม</td>
            <td><input name="fs28_1" type="number" value="0" class="k-textbox number" id="fs28_1"/></td>
            <td>1.ผ่าน, 2.ไม่ผ่าน</td>
          </tr>
          <tr>
            <td>รอยหยักฟันปลา</td>
            <td><input name="fs20_1" type="number" value="0" class="k-textbox number" id="fs20_1"/></td>
            <td>mm.</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>เฉดสีกระดาษ</td>
            <td><input name="fs21_1" type="number" value="0" class="k-textbox number" id="fs21_1"/></td>
            <td>1 = ไม่ต่าง,2= แตกต่าง</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><strong>ปัญหาที่พบตามลักษณะ</strong></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </tbody>
      </table>
    <script>
                $(document).ready(function() {
                    $("#grid").kendoGrid({
						columns: [
						{ field: "rank", width: "40px" },
						{ field: "rating", width: "10px" },
						{ field: "title",  width: "20px" },
						{ field: "year", width: "40px" },
						{ field: "dse", width: "10px" },
						{ field: "asa", width: "20px" }
						],
                        //height: 1000,
						//pageable: true,
						dataSource: {
						//pageSize: 12
						} 
                    });
                });
            </script></td>
  </tr>
</table>

<!--scrip list select--> 
<script>
                $(document).ready(function() {
                    var viewModel = {
                        chosenTicket: ko.observable(),
                        resetTicket: function() { this.chosenTicket(null) },
                    };
                    $("#ticket1").kendoDropDownList().trigger("change");
                    $("#ticket2").kendoDropDownList().trigger("change");
                    $("#ticket3").kendoDropDownList().trigger("change");
                    $("#ticket4").kendoDropDownList().trigger("change");
                    $("#ticket5").kendoDropDownList().trigger("change");
                    $("#ticket6").kendoDropDownList().trigger("change");
                    $("#ticket7").kendoDropDownList().trigger("change");
                });
      		</script> 
<!--scrip วัน-เดือน-ปี--> 
<script>
                $(document).ready(function() {
                    var today = new Date(),
                        birthdays = [
                           +new Date(today.getFullYear(), today.getMonth(), 11),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 6),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 27),
                           +new Date(today.getFullYear(), today.getMonth() - 1, 3),
                           +new Date(today.getFullYear(), today.getMonth() - 2, 22)
                        ];

                    $("#datepicker").kendoDatePicker({
                        value: today,
                        month: {
                            // template for dates in month view
                            content: '# if ($.inArray(+data.date, [' + birthdays + ']) != -1) { #' +
                                         '<div class="birthday"></div>' +
                                     '# } #' +
                                     '#= data.value #'
                        },
                        footer: "Today - #=kendo.toString(data, 'd') #"
                    });

                    $("#datepicker").data("kendoDatePicker")
                                    .dateView.calendar.element
                                    .width(300);
                });
            </script> 
<!--scrip เวลา--> 
<script>
                $(document).ready(function() {
                    // create TimePicker from input HTML element
                    $("#timepicker").kendoTimePicker();
                });
            </script>
<script>
					$("#submit").click(function(){
					     var foliosheetFS1 = $("#ticket1").val();
                         var foliosheetFS2 = $("#ticket2").val(); 
                         var foliosheetFS3 = $("#ticket3").val();  
                         var foliosheetFS4 = $("#Problem").val();  
                         var foliosheetFS5 = $("#ticket4").val(); 
                         var foliosheetFS6 = $("#lot_no").val();
                         var foliosheetFS7 = $("#ticket5").val();
                         var foliosheetFS8 = $("#ticket6").val(); 
                         var foliosheetFS9 = $("#ticket7").val();
						 <?php 
                         	for($i=12;$i<=28;$i++){
                         		
                         	echo "var foliosheetFS".$i."_1 = $(\"#fs".$i."_1\").val(); \n";
                         	//echo "var finalcheckFC".$i."_2 = $(\"#fc".$i."_2\").val(); \n";	
                         	}
                         ?>  
                    if (confirm("ต้องการจะบันทึกข้อมูลหรือไม่ ?")) 
                        { 
		      //alert('<1>==>'+foliosheetFS12_1+'<2>==>'+foliosheetFS13_1+'<3>==>'+foliosheetFS14_1+'<4>==>'+foliosheetFS15_1);
			  var loading = "<img src='<?php echo base_url(); ?>css/BlueOpal/loading-image.gif?>'>";
		      $.ajax({
		      url : "<?php echo base_url();?>index.php/foliosheet/getDataFolioSheet",
		      type: "POST",
		      data:({  
			  foliosheetFS2 : foliosheetFS2,
			  foliosheetFS3 : foliosheetFS3,
			  foliosheetFS4 : foliosheetFS4,
			  foliosheetFS5 : foliosheetFS5,
			  foliosheetFS6 : foliosheetFS6,
			  foliosheetFS7 : foliosheetFS7,
			  foliosheetFS8 : foliosheetFS8,
			  foliosheetFS9 : foliosheetFS9,
			  <?php 
			  for($i=12;$i<=28;$i++){
			  echo "foliosheetFS".$i."_1 : foliosheetFS".$i."_1, \n";
			  //echo "finalcheckFC".$i."_2 : finalcheckFC".$i."_2, \n";
			  }?> 
			  foliosheetFS1 : foliosheetFS1
		        	}),
				beforeSend : function()
				{
		        $("#loading").html(loading);
		        //$("#overlay").css('display','block'); // displaying the overlay
		        // jQuery("#popup").css('display','block'); // displaying the popup
		        //$("#submit").attr("disabled","disabled");
		        },
		        success : function(rs)
				{
		        alert(rs);
		        $("#loading").html('');
		        //$("#submit").removeAttr("disabled","disabled");
				<?php 
		        for($i=12;$i<=28;$i++){
		        echo " $(\"#fs".$i."_1\").val('0'); \n";
		       // echo "  $(\"#fc".$i."_2\").val('0'); \n";	
		        }
		        ?> 
				}						
				})
				}
		        });
            </script>
